/*
 * SeqInBits.h
 *
 *  Created on: Mar 9, 2010
 *      Author: yanghoch
 */

#ifndef CSEQINBITS_H_
#define CSEQINBITS_H_
#include "bitsOperationUtil.h"
#include "SeedPattern.h"
#include "ReadInBits.h"
#include "boolFlagArray.h"
#include "stdafx.h"
#include "stdafx.h"

inline unsigned int lengthInWordSize(unsigned int uiSeqLength)
{
    return((uiSeqLength - 1) / wordSize + 2); // add one more
}

class CSeqInBits
{
public:
    CSeqInBits(unsigned int uiSeqLength = 0);
    CSeqInBits(const CSeqInBits& seqInBits); //Copy constructor
    virtual ~CSeqInBits();
    // Two arrays to store the string encoded with bits
    WORD_SIZE* pUpperBits;
    WORD_SIZE* pLowerBits;
    CboolFlagArray* pNBits;
    unsigned int uiSeqLength;
    void decode(char* caRead, int bufferSize);
    char* decodeSubStr(unsigned int start, unsigned int end, char* caRead, unsigned int BufferMAX);
    int allocBitStrSpace(unsigned int uiGenomeSize = 0);

    // get the wordSize substring encoded in bits and store in upperBits and lowerBits
    CReadInBits getSubstringInBits(unsigned int uiPosIndex) const;
    // eliminate the bits beyond read length. Not the length should smaller than word_size
    CReadInBits getSubstringInBits(unsigned int uiPosIndex, unsigned int uiSubstringLength) const;
protected:
    int initialization(unsigned int uiSeqLength = 0);
};
#endif /* CSEQINBITS_H_ */
